import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    footer: true,
    token: localStorage.getItem('token') || '',
    userId: localStorage.getItem('userId') || '',
    city: '',
    cityId: '110100',
    cinemaId: '',
    filmId: ''
  },
  mutations: {
    // 存储用户id
    setUserId(state, userId) {
      localStorage.setItem('userId', userId)
      state.userId = userId
    },
    // 存储token
    setToken(state, token) {
      localStorage.setItem('token', token)
      state.token = token
    },
    showFooter(state) {
      state.footer = true
    },
    hideFooter(state) {
      state.footer = false
    },
    // 获取城市名称
    city(state, city) {
      state.city = city
    },
    cityId(state, cityId) {
      state.cityId = cityId
    },
    cinemaId(state, cinemaid) {
      state.cinemaId = cinemaid
    },
    filmId(state, filmId) {
      state.filmId = filmId
    }
  },
  actions: {},
  modules: {}
})
